package com.csce.domain.entity.exam;

import cn.hutool.core.util.NumberUtil;
import com.osce.common.annotation.Excel;
import com.osce.common.core.entity.BaseEntity;
import lombok.*;

/**
 * 题目选项表对象 ex_questin_option
 *
 * @author zzx
 * @since 2023-07-31
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
@EqualsAndHashCode(callSuper = true)
public class ExQuestinOption extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 题目编号
     */
    @Excel(name = "题目编号")
    private Long questionId;

    /**
     * 序号
     */
    @Excel(name = "序号")
    private String index;

    /**
     * 内容
     */
    @Excel(name = "内容")
    private String content;

    /**
     * 是否正确
     */
    @Excel(name = "是否正确")
    private Object right;

    public void setRight(Object right) {
        if (right instanceof Boolean) {//布尔-前端传递参数
            this.right = (Boolean) right ? 1 : 2;
        } else if (right instanceof CharSequence && !NumberUtil.isNumber(right.toString())) { //字符串非数字-布尔-前端传递参数
            this.right = "true".equals(right.toString()) ? 1 : 2;
        } else {//数字-数据库
            this.right = Integer.parseInt(right.toString()) == 1;
        }
    }
}









